import Vue from 'vue'
import Router from 'vue-router'
// const _import = require('./_import_' + process.env.NODE_ENV)
import layout from '../views/layout/Layout'

Vue.use(Router)

const _view = file => require(`@/views/${file}`)

//固定路由
export const constantRouterMap = [
  {
    path: '/',
    name: 'home',
    component: layout,
    redirect: '/home',
    hidden: true,
    children: [
      {
        path: 'home',
        component: _view('Index')
      }
    ]
  },
  {
    path: '/hello/:name?',
    name: 'hello',
    component: _view('Hello'),
    hidden: true
  },
  {
    path: '/login',
    name: 'login',
    component: _view('account/login'),
    hidden: true
  },
  {
    path: '/chat/:name',
    name: 'chat',
    component: _view('Chat'),
    hidden: true
  },
  {
    path: '/max_screen/:code',
    name: 'maxScreen',
    component: _view('MaxScreen'),
    hidden: true
  },
  {
    path: '/max/:code',
    name: 'max',
    component: _view('Max'),
    hidden: true
  },
  {
    path: '*',
    component: {
      template: '<div>404</div>'
    }
  }
]

export default new Router({
  mode: 'history', //后端支持可开
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})

//动态路由
export const asyncRouterMap = []
